package ubiqweb.spring3.service;

import java.util.List;

import ubiqweb.spring3.model.Training;
import ubiqweb.spring3.dao.TrainingDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("trainingService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class TrainingServiceImpl implements TrainingService {
	
	@Autowired
	private TrainingDao trainingDao;

	public TrainingServiceImpl() {
	}

	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void addTraining(Training training) {
		trainingDao.saveTraining(training);
	}

	public List<Training> listTrainings(){
		return trainingDao.listTrainings();
	}
	
	public List<Training> listTrainings(String trainingId){
		return trainingDao.listTrainings(trainingId);
	}


}